﻿using System.Collections;
using System.Collections.Generic;
using System.Xml.Linq;

namespace umbraco.DataServices.Linq {

    public class NodeIterator : IEnumerable<UmbracoNode> {

        private readonly IEnumerable<XElement> _elements;
        private readonly UmbracoContext _context;
        public IEnumerable<string> TargetAliases { get; set; }

        public NodeIterator(UmbracoContext context, IEnumerable<XElement> elements, string targetAlias) {
            _elements = elements;
            _context = context;
            TargetAliases = new[] { targetAlias };
        }

        public NodeIterator(UmbracoContext context, IEnumerable<XElement> elements, IEnumerable<string> targetAliases) {
            _elements = elements;
            _context = context;
            TargetAliases = targetAliases;
        }

        public IEnumerator<UmbracoNode> GetEnumerator() {
            return new NodeEnumerator(_context, _elements, TargetAliases);
        }

        IEnumerator IEnumerable.GetEnumerator() {
            return GetEnumerator();
        }

        public IEnumerable<XElement> Aliases { get { return _elements; } }

    }

}
